<#include "/layout/layout.ftl">
<#import "/layout/macro.ftl" as macro>
<#import "/layout/select.ftl" as my/>
<#assign css>
<#--此ftl中用到的css-->
</#assign>
<#assign js>
<#--此ftl中用到的js-->
<script>

	function calc(obj){

	    var amt = obj.value;
	    if(!isNaN(amt)){
	       var fee = (amt * ${draw_rate} /100).toFixed(2);
			$("#fee").val(fee<0.1?0.1:fee);
		}
	}

	$(".btn-submit").click(function () {
		// 校验表单合法
		var bootstrapValidator = $(".form-edit").data('bootstrapValidator');
		bootstrapValidator.validate();
		if(bootstrapValidator.isValid()){
			$.ajax({
				type: "POST",
				url: "/agentDrawApply/edit",
				data: $(".form-edit").serialize(),
				dataType: "JSON",
				success: function(res){
					layer.msg(res.message, {time: 2000
					}, function(){
						location.href="/agentDrawApply/index";
					});
				}
			});
		}else{
			return false;
		}
	});

	$('.form-edit').bootstrapValidator({
		message: '请输入有效值',
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		},

        fields: {
            amount: {
                message: '提现金额不能为空',//默认提示信息
                validators: {
                    notEmpty: {
                        message: '提现金额不能为空'
                    },
                    numeric: {
                        message: '提现金额请输入正确数字'
                    },
					callback:{
                        message:'提现金额请输入大于0.1并且小于账户余额${balance?string('0.00')}',
						callback:function(value, validator,$field){
                            if(value>${balance?string('0.00')}||value<=0.1){
                                return false;
							}

							return true;

						}
					}

                }
            }

        }
	});

</script>
</#assign>
<@layout title="编辑" active="agentDrawApply">
<!-- Content Header (Page header) -->
<section class="content-header">
	<h1>
		<#if isAdd>
            新增
        <#else>
            编辑
        </#if>
		<small>分站提现申请详细信息</small>
	</h1>
	<ol class="breadcrumb">
		<li><a href="/"><i class="fa fa-home"></i> 管理后台</a></li>
		<li><a href="#"><i class="fa fa-list-ul"></i> 分站提现申请管理</a></li>
		<li class="active"><i class="fa fa-edit"></i>
		    <#if isAdd>
                新增
            <#else>
                编辑
            </#if>
		</li>
	</ol>
</section>
<!-- Main content -->
<section class="content">
	<div class="row">
		<div class="col-md-12">
			<!-- Default box -->
			<div class="box  box-primary">
				<form class="form-horizontal form-edit" method="post" action="agentDrawApply/edit">
					<div class="box-body">
						<input type="hidden" id="id" name="id" value="${agentDrawApply.id!}">
						<input type="hidden" id="isAdd" name="isAdd" value="${isAdd?string('true','false')}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">银行卡号：</label>
                            <div class="col-sm-5">
								<input class="form-control" type="text" value="${agentDrawApply.account!}" disabled>
                                <input  placeholder="请输入银行卡号" id="account" autocomplete="off" name="account" class="form-control" type="hidden" value="${agentDrawApply.account!}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">户名：</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" value="${agentDrawApply.accountName!}" disabled>
                                <input placeholder="请输入户名" id="accountName" autocomplete="off" name="accountName" class="form-control" type="hidden" value="${agentDrawApply.accountName!}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">卡户银行：</label>
                            <div class="col-sm-5">
                                <input class="form-control" type="text" value="${agentDrawApply.openBank!}" disabled>
                                <input placeholder="请输入开户银行" id="openBank" autocomplete="off" name="openBank" class="form-control" type="hidden" value="${agentDrawApply.openBank!}" >
                            </div>
                        </div>
						<div class="form-group">
							<label class="col-sm-2 control-label">提现金额：</label>
							<div class="col-sm-5">
								<input required placeholder="请输入提现金额" id="amount" name="amount" autocomplete="off" onkeyup="calc(this)" type="text" class="form-control" value="${agentDrawApply.amount!}" >
								<span>当前账户余额 ${balance?string('0.00')!} 元,提现收取 ${draw_rate}%  的手续费<span>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-2 control-label">手续费：</label>
							<div class="col-sm-5">
								<input required id="fee" name="fee" class="form-control" type="text" value="${agentDrawApply.fee!}" readonly >
							</div>
						</div>


					<div class="box-footer">
						<button type="button" class="btn btn-default btn-back">返回</button>
						<button type="button" class="btn btn-info pull-right btn-submit" <#if !agentDrawApply.account??>disabled</#if>>提交</button>
						<#if !agentDrawApply.account??>
							<font style="color:red">提现银行卡号未维护，请联系管理员</font>
						</#if>
					</div>

				</form>
			</div>
			<!-- /.box -->
		</div>
	</div>
</section>
<!-- /.content -->
</@layout>
